package com.bawei.mdm2207alast.apps

import com.bawei.mdm2207alast.base.BaseViewModel
import com.bawei.mdm2207alast.base.IUiIntent
import com.bawei.mdm2207alast.model.DownloadUtil
import com.bawei.mdm2207alast.model.RetrofitManager

/**
 * 作者：赵亮
 * 时间：2024/12/17 11:07
 * 功能：应用模块的viewModel 和 view层交互的中间层
 */
class AppsViewModel : BaseViewModel() {
    override fun handIntent(it: IUiIntent) {
        when (it) {
            is AppsIntent.SelClientApp -> {
                // 客户端查询app
                httpRequest(RetrofitManager.apiService.selClientApp(it.map))
            }

            is AppsIntent.DownloadApp -> {
                // 下载app
                DownloadUtil.download(it.context, it.url, it.fileName)
            }
        }
    }
}